Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 5 - Objects and References / Reference Forms


Index

The Index reference form specifies an object or a location by describing its position with respect to the beginning or end of a container.

SYNTAX
className [ index ] integer 
integer(st | nd | rd | th ) className 
( first | second | third | fourth | fifth | sixth |
    seventh | eighth | ninth | tenth ) className          
( last | front | back ) className   
where

className is the class identifier of the object being specified.

integer is an integer that describes the position of the object in relation to the beginning of the container (if integer is a positive integer) or the end of the container (if integer is a negative integer).

The forms first, second, and so on are equivalent to the corresponding integer forms (for example, second word is equivalent to word 2). For objects whose index is greater than 10, you can use the forms 12th, 23rd, 101st, etc. (Note that any integer followed by any of the suffixes listed is valid; for example, you can use 11rd to refer to the eleventh object.)

The front form (for example, front window) is equivalent to className 1 or first className. The last and back forms (for example, last word and back window) refer to the last object in a container. They are equivalent to className -1.

The following forms refer to insertion points and are used to specify locations:

beginning | front  
end | back  
The beginning and front forms are equivalent and refer to the first insertion point of the container (insertion point 1). The end and back forms are equivalent and refer to the last insertion point of the container (insertion point -1).

EXAMPLES
The following references specify the second word from the beginning of the third paragraph.

word 2 of paragraph 3
2nd word of paragraph 3
second word of paragraph 3
The following references specify the last word in the third paragraph.

word -1 of paragraph 3
last word of paragraph 3
The following reference specifies the next-to-last word in the third paragraph.

word -2 of paragraph 3
The following references refer to the first insertion point of the document called Introduction.

beginning of document "Introduction"front of document "Introduction"
The following example contains two references. The first is a reference to the tenth word of the document called Introduction. The second is a reference to the last insertion point in the same document.

tell application "Scriptable Text Editor"   move word 10 of document "Introduction" to ÿ      end of document "Introduction"end tell

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996